package com.cloud.weichat;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

/**
 * Created by Army on 2013/10/18.
 */
public class SpringServiceLocator implements BeanFactoryAware {
	protected static BeanFactory beanFactory = null;

    protected static SpringServiceLocator servlocator = null;

    public void setBeanFactory(BeanFactory factory) throws BeansException {
        this.beanFactory = factory;
    }

    public BeanFactory getBeanFactory() {
        return beanFactory;
    }


    public static SpringServiceLocator getInstance() {
        if (servlocator == null)
            servlocator = (SpringServiceLocator) beanFactory.getBean("serviceLocator");
        return servlocator;
    }
}
